﻿/****************************************************************************************************
 **        Name: SQLErrorLog
 ** Description: Log of errros that occur while executing SQL.
 ****************************************************************************************************
 ** Revisions
 **  Date        Author               Work Item  Description
 **  ----------  -------------------  ---------  ----------------------------------------------------
 **  11/30/2008  Chad Green             11774    Initial Development
 **  02/21/2009  Chad Green             11774    Renamed the DateTime column to ErrorDateTime.
 **  02/21/2009  Chad Green             11774    Added the UserName column.
 **  02/21/2009  Chad Green             11774    Renamed the ERROR_LINE column to ErrorLine.
 **  02/21/2009  Chad Green             11774    Renamed the ERROR_MESSAGE column to ErrorMessage.
 **  02/21/2009  Chad Green             11774    Renamed the ERROR_NUMBER column to ErrorNumber.
 **  02/21/2009  Chad Green             11774    Renamed the ERROR_PROCEDURE column to ErrorProcedure.
 **  02/21/2009  Chad Green             11774    Renamed the ERROR_SEVERITY column to ErrorSeverity.
 **  02/21/2009  Chad Green             11774    Renamed the ERROR_STATE column to ErrorState.
 ****************************************************************************************************/

CREATE TABLE dbo.SQLErrorLog
(
	ID             int            NOT NULL IDENTITY(1,1),
	ErrorDateTime  dateTime       NOT NULL,
	ErrorLine      int            NOT NULL,
	ErrorMessage   nVarChar(4000) NOT NULL,
	ErrorNumber    int            NOT NULL,
	ErrorProcedure nVarChar(4000) NOT NULL,
	ErrorSeverity  int            NOT NULL,
	ErrorState     int            NOT NULL,
	Reviewed       bit            NOT NULL
)
GO
EXEC sp_addextendedproperty N'MS_Description', N'Maintains a log of errors that occur within the database.', 'SCHEMA', N'dbo', 'TABLE', N'SQLErrorLog', NULL, NULL
GO
EXEC sp_addextendedproperty N'MS_Description', N'Unique identifier for the error log entry.', 'SCHEMA', N'dbo', 'TABLE', N'SQLErrorLog', 'COLUMN', N'ID'
GO
EXEC sp_addextendedproperty N'MS_Description', N'The date and time the error occurred.', 'SCHEMA', N'dbo', 'TABLE', N'SQLErrorLog', 'COLUMN', N'ErrorDateTime'
GO
EXEC sp_addextendedproperty N'MS_Description', N'The line number at which the error occurred.', 'SCHEMA', N'dbo', 'TABLE', N'SQLErrorLog', 'COLUMN', N'ErrorLine'
GO
EXEC sp_addextendedproperty N'MS_Description', N'The message text of the error.', 'SCHEMA', N'dbo', 'TABLE', N'SQLErrorLog', 'COLUMN', N'ErrorMessage'
GO
EXEC sp_addextendedproperty N'MS_Description', N'The error number of the error.', 'SCHEMA', N'dbo', 'TABLE', N'SQLErrorLog', 'COLUMN', N'ErrorNumber'
GO
EXEC sp_addextendedproperty N'MS_Description', N'The name of the stored procedure or trigger where an error ocurred,', 'SCHEMA', N'dbo', 'TABLE', N'SQLErrorLog', 'COLUMN', N'ErrorProcedure'
GO
EXEC sp_addextendedproperty N'MS_Description', N'The severity of the error.', 'SCHEMA', N'dbo', 'TABLE', N'SQLErrorLog', 'COLUMN', N'ErrorSeverity'
GO
EXEC sp_addextendedproperty N'MS_Description', N'The state number of the error.', 'SCHEMA', N'dbo', 'TABLE', N'SQLErrorLog', 'COLUMN', N'ErrorState'
GO
EXEC sp_addextendedproperty N'MS_Description', N'Flag indicating whether the error log entry has been reviewed or not.', 'SCHEMA', N'dbo', 'TABLE', N'SQLErrorLog', 'COLUMN', N'Reviewed'
GO